/* Appendix D LNATEc1 */ 
clear all
cd "C:\2020 Spring\Vietnam Veteran\Crime\5. Table and Figures\RR Appendix D LNATEc1"
set matsize 1000
program drop _all
qui do CLR_01272015.ado  
qui do mcholx_01272015.ado

global outcomes1="currentViolent violent_desistence"

global outcomes="nonviolent_new nonviolent_desistance"

global outcomes2="currentViolent violent_desistence nonviolent_new nonviolent_desistance"

/*
use vc_nonviolent_new_ygroup2_white_nonwhite_test_I2_be, clear
qui bstat using vc_nonviolent_new_ygroup2_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b
*/

local i=1

*Crime Outcomes for white 1948-1952 compliers
foreach outcome in $outcomes1{ 

foreach race in 0 1 {
*Step 1. The crime LATE for the 1948-1950 white compliers 
use vc_`outcome'_ygroup1_white`race'_I2_be, clear
qui bstat using vc_`outcome'_ygroup1_white`race'_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,12]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,136]'
matrix list blL3
matrix buL3=b[1,137]'
matrix list buL3

matrix VblL3=Vb[136,136]
matrix list VblL3

matrix VbuL3=Vb[137,137]
matrix list VbuL3


set seed 1989
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90


*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}

*Generate variables needed for the figure 
*X-axis

gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,27]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_white`race'_LNATEc1_4852, replace
     }
local i=`i'+2	
 
}	 


local i=2

foreach outcome in $outcomes{
foreach year in 1 2 {
*White Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,120]'
matrix list blL3
matrix buL3=b[1,121]'
matrix list buL3

matrix VblL3=Vb[120,120]
matrix list VblL3

matrix VbuL3=Vb[121,121]
matrix list VbuL3


set seed 1989

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90



*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,11]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white1_LNATEc1, replace



*Nonwhite Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,584]'
matrix list blL3
matrix buL3=b[1,585]'
matrix list buL3

matrix VblL3=Vb[584,584]
matrix list VblL3

matrix VbuL3=Vb[585,585]
matrix list VbuL3

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}


set seed 1989
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90

*Generate variables needed for the figure 
*X-axis

gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,475]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white0_LNATEc1, replace
    }
local i=`i'+2

     }
	 


local i=1

*Crime Outcomes for white 1948-1950 compliers
foreach outcome in $outcomes1{ 

foreach race in 0 1 {
*Step 1. The crime LATE for the 1948-1950 white compliers 
use vc_`outcome'_ygroup2_white`race'_I2_be, clear
qui bstat using vc_`outcome'_ygroup2_white`race'_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,12]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,136]'
matrix list blL3
matrix buL3=b[1,137]'
matrix list buL3

matrix VblL3=Vb[136,136]
matrix list VblL3

matrix VbuL3=Vb[137,137]
matrix list VbuL3


set seed 1989
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90


*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}

*Generate variables needed for the figure 
*X-axis

gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,27]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_white`race'_LNATEc1_4850, replace
     }
local i=`i'+2	 
}	 



*Graph 1. Crime Outcomes for white 1948-1950 compliers
local i=2

foreach outcome in $outcomes{
foreach year in 2 {
*White Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,120]'
matrix list blL3
matrix buL3=b[1,121]'
matrix list buL3

matrix VblL3=Vb[120,120]
matrix list VblL3

matrix VbuL3=Vb[121,121]
matrix list VbuL3


set seed 1989

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90



*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,11]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white1_LNATEc1, replace



*Nonwhite Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,584]'
matrix list blL3
matrix buL3=b[1,585]'
matrix list buL3

matrix VblL3=Vb[584,584]
matrix list VblL3

matrix VbuL3=Vb[585,585]
matrix list VbuL3

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}


set seed 1989
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90

*Generate variables needed for the figure 
*X-axis

gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,475]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white0_LNATEc1, replace
    }
local i=`i'+2

     }


	 

*Graph 1. Crime Outcomes for currentViolent and violent desistance of 1950, 1951 and 1952
local i=1

foreach outcome in $outcomes2 {
foreach year in 3 4 5 {
*White Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,120]'
matrix list blL3
matrix buL3=b[1,121]'
matrix list buL3

matrix VblL3=Vb[120,120]
matrix list VblL3

matrix VbuL3=Vb[121,121]
matrix list VbuL3


set seed 1989

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90



*Generate variables needed for the figure 
*X-axis
gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,11]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white1_LNATEc1, replace



*Nonwhite Bars

*Step 1. The crime LATE for the 1948-1952 white compliers 
use vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be, clear
qui bstat using vc_`outcome'_ygroup`year'_white_nonwhite_test_I2_be
set more off

estat bootstrap,per

matrix b = e(b)
mat list b

matrix Vb = e(V)
matrix se = e(se)

sca N=b[1,1]
sca list N
set more off

*P3: LATE_at
matrix blL3=b[1,584]'
matrix list blL3
matrix buL3=b[1,585]'
matrix list buL3

matrix VblL3=Vb[584,584]
matrix list VblL3

matrix VbuL3=Vb[585,585]
matrix list VbuL3

*This part compute the p-value of the CI excluding 2SLS
local alpha=0.5
local alpha1000=`alpha'*1000 

CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'

local Llate3_at_`alpha1000'=Llate3_at_`alpha1000'[1,1]
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local Ulate3_at_`alpha1000'=Ulate3_at_`alpha1000'[1,1]
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]

*set pvalue=1
local pvalue=1

if `Llate3_at_`alpha1000''>0 & `alpha'>0 {
di "We are testing the lower bounds that is larger than 2SLS"
while `CILlate3_at_`alpha1000''>0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Llate3_at_`alpha1000'=e(Lstar)
mat list Llate3_at_`alpha1000'
mat CILlate3_at_`alpha1000'=e(CIL)
mat list CILlate3_at_`alpha1000'
local CILlate3_at_`alpha1000'=CILlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)	
      }
display "the CI of the lower bound reject zero at the level of `pvalue'" 
   } 
else {
if `Ulate3_at_`alpha1000''<0 & `alpha'>0 {
di "We are testing the upper bounds that is lower than 2SLS"
while `CIUlate3_at_`alpha1000''<0 & `pvalue'>=0.002 {
local alpha=`alpha'-0.001
local alpha1000=`alpha'*1000
di "Testing at level of `alpha'"
qui CLR blL3 VblL3 buL3 VbuL3 N 100000 `alpha'
mat Ulate3_at_`alpha1000'=e(Ustar)
mat list Ulate3_at_`alpha1000'
mat CIUlate3_at_`alpha1000'=e(CIU)
mat list CIUlate3_at_`alpha1000'
local CIUlate3_at_`alpha1000'=CIUlate3_at_`alpha1000'[1,1]
local pvalue=(`alpha'+0.001)
      }
display "the CI of the upper bound reject zero at the level of `pvalue'" 
   } 
}


set seed 1989
CLR blL3 VblL3 buL3 VbuL3 N 100000 0.05
mat Llate3_at_95=e(Lstar)
mat list Llate3_at_95
mat Ulate3_at_95=e(Ustar)
mat list Ulate3_at_95
mat CILlate3_at_95=e(CIL)
mat list CILlate3_at_95
mat CIUlate3_at_95=e(CIU)
mat list CIUlate3_at_95

CLR blL3 VblL3 buL3 VbuL3 N 100000 0.1
mat Llate3_at_90=e(Lstar)
mat list Llate3_at_90
mat Ulate3_at_90=e(Ustar)
mat list Ulate3_at_90
mat CILlate3_at_90=e(CIL)
mat list CILlate3_at_90
mat CIUlate3_at_90=e(CIU)
mat list CIUlate3_at_90

*Generate variables needed for the figure 
*X-axis

gen GROUP=`i'

gen L_LATE=Llate3_at_95[1,1]
gen U_LATE=Ulate3_at_95[1,1]
gen CI_L_LATE_95=CILlate3_at_95[1,1]
gen CI_U_LATE_95=CIUlate3_at_95[1,1]
gen CI_L_LATE_90=CILlate3_at_90[1,1]
gen CI_U_LATE_90=CIUlate3_at_90[1,1]
gen pvalue=`pvalue'
gen eyz0=b[1,475]

keep GROUP L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue

save Figure_`outcome'_yeargroup`year'_white0_LNATEc1, replace
    }
local i=`i'+1

     }


*1948-1952
*Collapse data together to make graphs 
use Figure_currentViolent_white1_LNATEc1_4852, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_violent_desistence_white1_LNATEc1_4852
append using Figure_nonviolent_new_yeargroup1_white1_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup1_white1_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_4850, replace 

use Figure_6_1_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -0.2(0.1)0.2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (A) White Compliers Born in 1948-1952") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_1_4852, replace 



*1948-1952 
*Collapse data together to make graphs 
use Figure_currentViolent_white0_LNATEc1_4852, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_violent_desistence_white0_LNATEc1_4852
append using Figure_nonviolent_new_yeargroup1_white0_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup1_white0_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_0_4850, replace 

use Figure_6_0_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname


gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -2(1)2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (B) Nonwhite Compliers Born in 1948-1952") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))


graph save Figure_6_0_4852, replace 
	 
*1948-1950	 
*Collapse data together to make graphs 
use Figure_currentViolent_white1_LNATEc1_4850, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_violent_desistence_white1_LNATEc1_4850
append using Figure_nonviolent_new_yeargroup2_white1_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup2_white1_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_4850, replace 

use Figure_6_1_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname


gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -0.2(0.1)0.2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  ///  
title("Panel (C) White Compliers Born in 1948-1950") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_1_4850, replace 



*1948-1950	 
*Collapse data together to make graphs 
use Figure_currentViolent_white0_LNATEc1_4850, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_violent_desistence_white0_LNATEc1_4850
append using Figure_nonviolent_new_yeargroup2_white0_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup2_white0_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_0_4850, replace 

use Figure_6_0_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname


gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -1(0.5)1, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (D) Nonwhite Compliers Born in 1948-1950") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_0_4850, replace 

*1950	 
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup3_white1_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup3_white1_LNATEc1
append using Figure_violent_desistence_yeargroup3_white1_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup3_white1_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_4850, replace 

use Figure_6_1_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -0.3(0.1)0.2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (E) White Compliers Born in 1950") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_1_1950, replace 

*1950	 
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup3_white0_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup3_white0_LNATEc1
append using Figure_violent_desistence_yeargroup3_white0_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup3_white0_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_4850, replace 

use Figure_6_1_4850, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -3(1)2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (F) Nonwhite Compliers Born in 1950") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_0_1950, replace 


*1951
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup4_white1_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup4_white1_LNATEc1
append using Figure_violent_desistence_yeargroup4_white1_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup4_white1_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_1951, replace 

use Figure_6_1_1951, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -0.4(0.2)0.2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (G) White Compliers Born in 1951") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_1_1951, replace 

*1951	 
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup4_white0_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup4_white0_LNATEc1
append using Figure_violent_desistence_yeargroup4_white0_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup4_white0_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_1951, replace 

use Figure_6_1_1951, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -2(1)2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (H) Nonwhite Compliers Born in 1951") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_0_1951, replace 



*1952
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup5_white1_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup5_white1_LNATEc1
append using Figure_violent_desistence_yeargroup5_white1_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup5_white1_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_1952, replace 

use Figure_6_1_1952, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -0.4(0.2)0.4, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  ///  
title("Panel (I) White Compliers Born in 1952") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_1_1952, replace 

*1952 
*Collapse data together to make graphs 
use Figure_currentViolent_yeargroup5_white0_LNATEc1, clear /* for 1948-1952 born whites and nonwhites  */
append using Figure_nonviolent_new_yeargroup5_white0_LNATEc1
append using Figure_violent_desistence_yeargroup5_white0_LNATEc1 /* for 1948-1952 born whites */
append using Figure_nonviolent_desistance_yeargroup5_white0_LNATEc1

*Step 5: Collapse the data 
collapse (mean) L_LATE U_LATE CI_L_LATE_95 CI_U_LATE_95 CI_L_LATE_90 CI_U_LATE_90 eyz0 pvalue, by(GROUP)
save Figure_6_1_1952, replace 

use Figure_6_1_1952, clear
label define groupname 1 "Violent Crime" 2 "Nonviolent Crime" 3 "Violent Recidivism" 4 "Nonviolent Recidivism"
label values GROUP groupname

gen PP_eyz0=eyz0*100 
gen PP_L_LATE=L_LATE*100
gen PP_U_LATE=U_LATE*100
gen PP_CI_L_LATE_95=CI_L_LATE_95*100
gen PP_CI_U_LATE_95=CI_U_LATE_95*100 
gen PP_CI_L_LATE_90=CI_L_LATE_90*100 
gen PP_CI_U_LATE_90=CI_U_LATE_90*100

*Step 4: Plot the scatter plot 
twoway (rbar PP_U_LATE PP_L_LATE GROUP, barwidth(0.5) color(gray) yline(0, lcolor(black)) xlab(1(1)4, valuelabel labsize(small))), /// 
ylabel( -4(2)2, labsize(small) grid glcolor(black) glwidth(medthick) glpattern(dot)) /// 
legend (order(1 "Effect Upper and Lower Bounds" 2 "90% CI" 3 "Mean Incarceration Rate of Ineligible-to-draft" 4 "95% CI"))  ///   
xtitle("")  /// 
title("Panel (J) Nonwhite Compliers Born in 1952") /// 
graphregion(color(white)) ///
|| (rcap PP_CI_U_LATE_95 PP_CI_L_LATE_95 GROUP, msize(vlarge) lwidth(median) color(black)) /// 
|| (scatter PP_eyz0 GROUP, msymbol(dot) msize(large) mlw(medthick) color(black)) ///
|| (rcap PP_CI_U_LATE_90 PP_CI_L_LATE_90 GROUP, msize(vlarge) lwidth(median) color(black))

graph save Figure_6_0_1952, replace 

graph combine Figure_6_1_4852.gph Figure_6_0_4852.gph Figure_6_1_4850.gph Figure_6_0_4850.gph, rows(2) cols(2) iscale(0.6) ysize(10) xsize(20)
graph combine Figure_6_1_1950.gph Figure_6_0_1950.gph Figure_6_1_1951.gph Figure_6_0_1951.gph, rows(2) cols(2) iscale(0.6) ysize(10) xsize(20)
graph combine Figure_6_1_1950.gph Figure_6_0_1950.gph Figure_6_1_1952.gph Figure_6_0_1952.gph, rows(2) cols(2) iscale(0.6) ysize(10) xsize(20)




